package com.linkedbear.springboot.assemble.c_conditional;

import com.linkedbear.springboot.assemble.c_conditional.config.TavernConfiguration;
import com.linkedbear.springboot.assemble.component.Bar;
import com.linkedbear.springboot.assemble.component.Boss;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

import java.util.stream.Stream;

public class TavernConditionalApplication {
    
    public static void main(String[] args) throws Exception {
        AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(TavernConfiguration.class);
        Stream.of(ctx.getBeanDefinitionNames()).forEach(System.out::println);
        System.out.println("===============");
        try {
            //Boss boss = (Boss)ctx.getBean("boss");
            Boss boss = ctx.getBean(Boss.class);
            boss.setAge(20);
            boss.setName("jj");
            System.out.println(boss);
//            Thread.sleep(10000);
            Bar bbbar = (Bar) ctx.getBean("bbbar");
            bbbar.setName("zzz");
            System.out.println(bbbar);
        }catch (Exception e){
            e.printStackTrace();
        }
//        String[] beanDefinitionNames = ctx.getBeanDefinitionNames();
//        for (int i = 0; i < beanDefinitionNames.length; i++) {
//            System.out.println(beanDefinitionNames[i]);
//        }
    }
}
